<template>
  <div>
    <el-card style="margin:20px;" >
      <div slot="header" class="clearfix">
        <span>商城首页配置</span>
      </div>
      <el-form :model="formData">
        <el-form-item label='商城名称' prop="shopping_mall_address"  label-width="300px" style="font-weight:bold">
          <el-input style="width:600px" v-model="formData.shopping_mall_address" size="medium" ></el-input>
        </el-form-item>
        <el-form-item label='商城地址' prop="shopping_mall_name"  label-width="300px" style="font-weight:bold">
          <el-input style="width:600px" size="medium" v-model="formData.shopping_mall_name"></el-input>
        </el-form-item>
        <el-form-item label='联系电话' prop="shopping_mall_phone"  label-width="300px" style="font-weight:bold">
          <el-input style="width:600px" size="medium" v-model="formData.shopping_mall_phone" ></el-input>
        </el-form-item>
        <el-form-item label='联系QQ' prop="shopping_mall_qq" label-width="300px" style="font-weight:bold">
          <el-input style="width:600px" size="medium" v-model="formData.shopping_mall_qq"></el-input>
        </el-form-item>
        
      </el-form>

      <div class="bottom" style="display:flex;justify-content:right">
        <el-button @click="confirm" type="primary">确定</el-button>
        <el-button @click="cancel">取消</el-button>
      </div>
    </el-card>
  </div>
</template>
  
<script>
import axios from 'axios'
export default {
  name: 'shopMallInfoConfig',
  componentTitle: '商城信息配置',
  data () {
    return {
      formData:{
        shopping_mall_address:'',
        shopping_mall_name:"",
        shopping_mall_phone:"",
        shopping_mall_qq:"",
   
      }
    }
  },
  mounted(){
this.search()
  },
  methods:{
    search(){
      axios({
      url:'http://192.168.200.251:8888/admin/config/mall',
      method:'get',
      params:{
        ...this.formData
      },
      headers:{'shopping-admin-token':sessionStorage.getItem('shopping-admin-token')}
      }).then(res=>{
        this.formData=res.data.data

      })
    },
    confirm(){
       axios({
      url:'http://192.168.200.251:8888/admin/config/mall',
      method:'post',
      data:{
        ...this.formData
      },
      headers:{'shopping-admin-token':sessionStorage.getItem('shopping-admin-token')}
      }).then(res=>{
        if(res.data.errno==0){
          this.cancel()
          this.$notify.success({title: '编辑成功'})
          this.search()
        }else{
           this.$notify.success({title: '编辑失败'})
        }

      })
    },
    cancel(){
      this.search()
    },
  }
}
</script>

